<?php
session_start();
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/database.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/functions.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/class.admin.php');
$admin = new admin();
$admin->canView($_SERVER['PHP_SELF']);
ob_start("sanitize_output"); 
$pages=$admin->showPages(); // it's in $pages['results'];
?>

<h2 class="form-heading">Current Pages</h2>
<table width="99%" class="headed-table">
	<thead>
    <tr valign="top">
    <td width="1%" class="hleft"></td>
    <td width="25%"><h6>&nbsp;Page name</h6></td>
	<td width="25%"><h6>&nbsp;Parent</h6></td>
    <td width="10%"><h6>&nbsp;Path/Url</h6></td>
	<td width="5%" class="hright"></td>
</tr>
</thead>
<tbody>
	<?php
	$i=0;
	foreach($pages as $page) {
		$bg=($i%2) ? ' odd' : '';
		
		$parent=($page['is_parent']=='1') ? 'Yes' : 'No';
//print_r($page);

		echo('<tr valign="top">');//class="'.trim($bg).'"
			echo('<td class="left'.$bg.'" width="1%"><a href="/admin/resources/php/requests/actions/delete-page.php?id='.(string)$page['id'].'" class="delete-page tip" title="Delete this page"><img src="/admin/resources/images/cancel.png" /></a></td>');
			echo('<td class="'.$bg.'" width="25%">'.$page['text'].'</td>');
			echo('<td class="'.trim($bg).'" width="25%">'.$parent.'</td>');
			echo('<td class="'.trim($bg).'" width="10%">'.$page['url'].'</td>');
			echo('<td class="right'.$bg.'" width="5%" style="text-align:right;"><a href="/admin/resources/php/requests/forms/edit-page.php?id='.$page['id'].'&url='.$page['url'].'&type=content" class="page-edit"><img src="/admin/resources/images/b_edit.png" /></a></td>');
		echo('</tr>');
		$i++;
	}
	
	
	?>
</tbody>

</table>